﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ncp.Web.uc
{
    public partial class shopHeader : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                var shopId = Request.QueryString["shop"];
                var product_type = Request.QueryString["product_type"];
                int id = 0;
                if (!int.TryParse(shopId, out id))
                {
                    Response.Redirect("/shop/error.html");
                }
                //获取地址
                var url = Request.Url.ToString().ToLower();
                IList<string> pages=new List<string>();
                pages.Add("/shop/about.html");
                pages.Add("/shop/product.html");
                pages.Add("/shop/buyingleads.html");
                pages.Add("/shop/case.html");
                pages.Add("/shop/company.html");
                pages.Add("/shop/join.html");
                pages.Add("/shop/message.html");
                pages.Add("/shop/contact.html");
                IList<string> name=new List<string>();
                name.Add("关于我们");
                name.Add("产品展示");
                name.Add("求购信息");
                name.Add("成功案例");
                name.Add("企业动态");
                name.Add("招商加盟");
                name.Add("站内留言");
                name.Add("联系我们");
                StringBuilder builder=new StringBuilder();
                for (int i = 0; i < pages.Count; i++)
                {
                    builder.Append("<li class=\"");
                    if (i==0)
                    {
                        builder.Append("index");
                    }
                    if (url.Contains(pages[i].Replace("/shop/","").Replace(".html","")))
                    {
                        builder.Append(" on");
                    }
                    if (product_type!=null&&pages[i].Contains("product"))
                    {
                        builder.AppendFormat("\"><a href=\"{0}\">{1}</a></li>", pages[i].Replace("shop", "shop" + shopId).Replace(".html","-"+product_type+".html"), name[i]);
                    }
                    else
                    {
                        builder.AppendFormat("\"><a href=\"{0}\">{1}</a></li>", pages[i].Replace("shop", "shop" + shopId) , name[i]);
                    }

                }
                ltMenu.Text = builder.ToString();
            }
        }
    }
}